package MetaClassifierAlgorithms;

import java.util.Arrays;

import Definitions.GraphClass;
import Global.GlobalClass;
import Sampling.SamplingAbstractClass;
import Utility.WorkerUtilityClass;

public class ProdMetaClassifierClass  extends MetaClassifierAbstractClass {
	ProdMetaClassifierClass(String metaClassifierName, GraphClass graph,
			GlobalClass global, SamplingAbstractClass currentSampling, double[][][] probabilityDistributionMatrixForTheClassifiers) {
		
		super(metaClassifierName, graph, global, currentSampling, probabilityDistributionMatrixForTheClassifiers);
		// TODO Auto-generated constructor stub
	}

	public void metaClassify()
	{
		double prodOfTheProbabilitiesPerClassBasis[] = new double[global.classSize];
		int metaClassLabelEstimated;
		
		for(int nodeNo=0; nodeNo<probabilityDistributionMatrixForTheClassifiers[0].length; nodeNo++)
		{
			Arrays.fill(prodOfTheProbabilitiesPerClassBasis,0.0);
			
			for(int j=0; j<probabilityDistributionMatrixForTheClassifiers.length; j++)
			{
				prodOfTheProbabilitiesPerClassBasis = WorkerUtilityClass.getVectoralProductOfTheDoubleArrays(prodOfTheProbabilitiesPerClassBasis, probabilityDistributionMatrixForTheClassifiers[j][nodeNo]);
				//WorkerUtilityClass.printArray(probabilityDistributionMatrixForTheClassifiers[j][nodeNo], "siniflandirici:"+j);
			}
			//WorkerUtilityClass.printArray(metaResultProbabilitiesPerClassBasis, "metaResultProbabilitiesPerClassBasis(AVE):");
			
			
			metaClassLabelEstimated = WorkerUtilityClass.findMaxIndexForTheGivenVector(prodOfTheProbabilitiesPerClassBasis);
			
			//System.out.println("metaClassLabelEstimated:"+metaClassLabelEstimated+" " + "Actual:" + currentSampling.getTestNodes().get(nodeNo).getClassOrder());
			//WorkerUtilityClass.printShorterSeperator();
			
			currentSampling.setClassLabelEstimated(currentSampling.getTestNodes().get(nodeNo), metaClassLabelEstimated);			
		}		
	}
}
